import { requestClient } from '#/api/request';

// 团队信息接口类型
export interface TeamInfo {
  id: string;
  teamName: string;
  type: string;
  organName: string;
  province: string;
  captainName: string;
  memberCount: number;
  compName: string;
  createTime: string;
  status: string;
}

// 查询参数类型
export interface TeamInfoQueryParams {
  name?: string;
  type?: string;
  organName?: string;
  province?: string;
  compId?: string;
  createStartTime?: string;
  createEndTime?: string;
  curPage?: number;
  pageSize?: number;
}


// 团队成员参数类型
export interface TeamMembersQueryParams {
  teamId: string;
  curPage: number;
  pageSize: number;
}

// 团队成员类型
export interface TeamMember {
  id: string;
  teamId: string;
  name: string;
  phone: string;
  email: string;
  role: string;
  position: string;
  photoName: string;
}

// 团队成员响应类型
export interface TeamMembersResponse {
  data: TeamMember[];
  pageInfo: {
    totalRows: number;
    curPage: number;
    pageSize: number;
  };
}

// 分页响应类型
export interface TeamInfoPageResponse {
  data: TeamInfo[];
  pageInfo: {
    totalRows: number;
    curPage: number;
    pageSize: number;
  };
}

/**
 * 获取团队信息分页列表
 */
export async function getTeamInfoPageApi(params: TeamInfoQueryParams): Promise<TeamInfoPageResponse> {
  return requestClient.get('/match/query-team-info-list', { params });
}

// 导出参数类型
export interface ExportTeamInfoParams {
  idList: string[];
}

/**
 * 导出团队信息
 */
export async function exportTeamInfoApi(data: ExportTeamInfoParams): Promise<Blob> {
  return requestClient.post('/match/export-team-info-list', data, { 
    responseType: 'blob',
    headers: {
      'Accept': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel'
    }
  });
}
/**
 * 获取团队成员
 */
export async function getTeamMembersApi(data: TeamMembersQueryParams): Promise<TeamMembersResponse> {
  return requestClient.get('/match/get-team-members-info', { params: data });
}
